package com.cysyz.mylib.datacopytool.getterandsetteradapter;

import com.cysyz.mylib.datacopytool.GetterAndSetterType;

import java.util.Properties;

public class JavaPropertiesGetterAndSetterAdapter implements GetterAndSetterAdapter {

	@Override
	public boolean supports(Object obj) {
		if (obj instanceof Properties) {
			return true;
		}
		return false;
	}

	@Override
	public Object getValue(Object obj, String valueId) {
		return ((Properties) obj).getProperty(valueId);
	}

	@Override
	public void setValue(Object obj, String valueId, Object val) {
		throw new UnsupportedOperationException();
	}

	@Override
	public GetterAndSetterType getGetterAndSetterType() {
		return GetterAndSetterType.KEYWORD;
	}

	@Override
	public String[] getAllValueIds(Object obj) {
		String[] result = new String[] {};
		return ((Properties) obj).stringPropertyNames().toArray(result);
	}

}
